package com.yf.catcafe.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.nio.file.Paths;

@Configuration
public class StaticResourceConfiguration implements WebMvcConfigurer {

    private static final String UPLOAD_DIR = "D:/CatCafeUploads/";
    private static final String UPLOAD_DIR2 = "D:/CafeUploads/";
    private static final String UPLOAD_DIR3 = "D:/UserUploads/";

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/uploads/**")
                 .addResourceLocations("file:" + Paths.get(UPLOAD_DIR).toAbsolutePath() + "/")
                .addResourceLocations("file:"+Paths.get(UPLOAD_DIR2).toAbsolutePath()+"/")
                .addResourceLocations("file:"+Paths.get(UPLOAD_DIR3).toAbsolutePath()+"/");
    }
}
